package com.eystar.ext.aop;

import com.eystar.ext.kit.page.PageOrder;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class PageInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		// 说明该Controller需要分页
		if (controller.getParaToInt("rows") != null && controller.getParaToInt("page") != null) {
			PageOrder order = new PageOrder(controller.getParaToInt("page"), controller.getParaToInt("rows"));
			order.setOrder(controller.get("sort"));
			order.setOrderType(controller.get("order"));
			controller.setAttr("PageOrder", order);
		}
		inv.invoke();
	}

}
